const form=document.querySelector('.form')
const submit=document.querySelector('.btn')
submit.addEventListener('click',function(e){
    e.preventDefault();
    let isvalid=true
const username=document.querySelector('input[name="username"]')
const password=document.querySelector('input[name="password"]')
let uv=username.value;
let pv=password.value;
const passwordspan=password.nextElementSibling;
const usernamespan=username.nextElementSibling
const obj={
    username:uv,
    password:pv
}
if (!uv) {
    usernamespan.innerHTML = '用户名不能为空';
 isvalid=false
}
if (!pv) {
    passwordspan.innerHTML = '密码不能为空';
    isvalid=false
}
if(!isvalid){
  return;
}


axios({
    url:'http://127.0.0.1:4523/m1/6252606-5946561-default/m1/6252606-5946561-default/user',
method:'get',
    params:{
        username:uv,
        password:pv
    }
}).then(result=>{
console.log(result);
alert('登陆成功')
})    .catch(error => {
    console.log(error);
    if(error.request.status==='401')
    alert('用户未注册')
    
  });


})